import pymysql
conn=pymysql.connect(
    host='127.0.0.1',
    port=3306,
    user='root',
    password='root',
    db='test',
    charset='utf8'
)
cursor=conn.cursor()
sql='select * from test_emp1'
print('%s',sql)
rows=cursor.execute(sql)
print(cursor.fetchone())
cursor.close()
conn.close()
if rows>=0:
    print('连接成功；')
else:
    print('连接失败；')